/******************************************************************************
 * Filename : uc_shrm.h
 * Copyright: 
 * Created  : 2010-11-9 by franco.yin
 * Description -
 * 
 ******************************************************************************/

#ifndef _UC_SHRM_H
#define _UC_SHRM_H

#ifdef __cplusplus
extern "C" {
#endif

#include "uc_public.h"
#include "uc_list.h"
#include "uc_hash.h"

#define SHRM_PATH_LEN 50

typedef int (*ucshrm_walk_fun) (ucnode_s * pNode, int ext, void *p);
typedef int (*ucshrm_create_key) (ucnode_s * pNode, void *p);

typedef struct ucshrm {
	int shrmid;
	key_t key;
	char *ptr;
} ucshrm_s;

typedef struct ucshrm_hash_node {
	ucnode_s list;
} ucshrm_hash_node_s;

typedef struct ucshrm_hash_table {
	ucshrm_hash_node_s *pHead;
	int size;
	ucshrm_create_key pCreat_key;
	void *p;
} ucshrm_hash_table_s;

extern int ucshrm_init(ucshrm_s * pshr, key_t key, int size);
extern char *ucshrm_attach(ucshrm_s * pshr);
extern void ucshrm_detach(ucshrm_s * pshr);
extern void ucshrm_free(ucshrm_s * pshr);
extern char *ucshrm_hash_creat(int size, char **pTail, ucshrm_create_key pFun, void *p);
extern int ucshrm_hash_add(ucnode_s * pNode, char *pTable);
extern ucnode_s *ucshrm_hash_walk(char *table, int ext, int key, ucshrm_walk_fun func, void *p);

#ifdef __cplusplus
}
#endif

#endif				/* _UC_SHRM_H */
